<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link href="${pageContext.request.contextPath}/statics/css/common.css" rel="stylesheet" type="text/css" />
    <link href="${pageContext.request.contextPath}/statics/css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
        function $(id){
            return document.getElementById(id);
        }
        function checkAuctionName(){
            if($("auctionName").value==""){
                $("nameid").style.display="block";
                return false;
            }else{
                $("nameid").style.display="none";
                return true;
            }
        }

        function checkStartPrice(){
            if(($("startPrice").value=="")||(isNaN($("startPrice").value)==true)){
                $("startPriceid").style.display="block";
                return false;
            }else{
                $("startPriceid").style.display="none";
                return true;
            }
        }

        function checkUpset(){
            if(($("upset").value=="")||(isNaN($("upset").value)==true)){
                $("upsetid").style.display="block";
                return false;
            }else{
                $("upsetid").style.display="none";
                return true;
            }
        }

        function checkStartTime(){
            if($("startTime").value==""){
                $("startTimeid").style.display="block";
                return false;
            }else{
                $("startTimeid").style.display="none";
                return true;
            }
        }

        function checkEndTime(){
            if($("endTime").value==""){
                $("endTimeid").style.display="block";
                return false;
            }else{
                $("endTimeid").style.display="none";
                return true;
            }
        }
        function checkValue(){
            if((checkAuctionName()&&checkStartPrice()&&checkUpset()&&checkStartTime()&&checkEndTime())==true){
                if($("pic").value==""){
                    $("picid").style.display="block";
                    return false;
                }else{  q
                    $("picid").style.display="none";
                    return true;
                }
            }
            return false;
        }
        // function showPic(){
        //     $("#imgid").src=$("[name='pic']").val();/*考虑到安全性和兼容性问题，发布拍卖品时，图片可以不显示*/
        // }

        function show(file){
            var reader = new FileReader();    // 实例化一个FileReader对象，用于读取文件
            var img = document.getElementById('img');     // 获取要显示图片的标签

            //读取File对象的数据
            reader.onload = function(evt){
                img.width  =  "80";
                img.height =  "80";
                img.src = evt.target.result;
            }
            reader.readAsDataURL(file.files[0]);
        }
    </script>
</head>

<body>
<form action="${pageContext.request.contextPath}/SupAuction" enctype="multipart/form-data" method="post" onsubmit="return checkValue()">
    <div class="wrap">
        <!-- main begin-->
        <div class="sale">
            <h1 class="lf">在线拍卖系统</h1>
            <c:if test="${not empty auctionUserSession}">
                <div class="logout right"><a href="doLogout" title="注销">注销</a></div>
            </c:if>
            <c:if test="${empty auctionUserSession}">
                <div class="logout right"><a href="login.jsp" title="登录">登录</a></div>
            </c:if>
        </div>
        <div class="login logns produce">
            <h1 class="blues">拍卖品信息</h1>
            <input type="hidden" name="auctionId" value="${auction.auctionId}">
            <dl>
                <dd >
                    <label>名称：</label>
                    <input type="text" onblur="checkAuctionName()" name="auctionName" class="inputh lf" value="${auction.auctionName}" />
                    <div id="nameid" class="lf red laba">名称不能为空</div>
                </dd>
                <dd>
                    <label>起拍价：</label>
                    <input type="text" onblur="checkStartPrice()" name="auctionStartPrice" class="inputh lf" value="${auction.auctionStartPrice}" />
                    <div id="startPriceid" class="lf red laba">必须为数字</div>
                </dd>
                <dd>
                    <label>底价：</label>
                    <input type="text" name="auctionUpset" class="inputh lf" onblur="checkUpset()" value="${auction.auctionUpset}" />
                    <div id="upsetid" class="lf red laba">必须为数字</div>
                </dd>
                <dd>
                    <label>开始时间：</label>
                    <input type="text" name="auctionStartTime" class="inputh lf" value="<fmt:formatDate value="${auction.auctionStartTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" onblur="checkStartTime()"/>
                    <div id="startTimeid" class="lf red laba">格式：2010-05-05 12:30:00</div>
                </dd>
                <dd>
                    <label>结束时间：</label>
                    <input type="text" name="auctionEndTime" class="inputh lf" value="<fmt:formatDate value="${auction.auctionEndTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" onblur="checkEndTime()"/>
                    <div id="endTimeid" class="lf red laba">格式：2010-05-06 16:30:00</div>
                </dd>
                <dd class="dds">
                    <label>拍卖品图片：</label>
                    <div class="lf salebd"><img id="img" src="/imga/${auction.auctionPic}" width="100" height="100" /></div>
                    <input name="pic" type="file" class="offset10 lf" onchange="show(this)"/>
                    <div id="picid" class="lf red laba">请上传图片</div>
                </dd>
                <dd class="dds">
                    <label>描述：</label>
                    <textarea  name="auctionDesc" cols="" rows="" class="textarea">${auction.auctionDesc}</textarea>
                </dd>
                <dd class="hegas">
                    <input type="submit" value="修 改" class="" />
                    <input type="reset" value="取 消" class="" onclick="history.go(-1)" />
                </dd>
            </dl>
        </div>
        <!-- main end-->
        <!-- footer begin-->

    </div>
    <!--footer end-->

</form>
</body>
</html>
